package com.cidp.system.service.impl;

import com.cidp.system.dao.IDepartmentDao;
import com.cidp.system.model.Tdepartment;
import com.cidp.system.service.IDepartmentService;
import com.litt.core.exception.BusiException;
import com.litt.core.page.IPageList;
import com.litt.core.page.PagePoParam;

/**
 * <b>标题：</b>系统部门Service实现.
 * <pre><b>描述</b>
 *    系统部门管理
 * </pre>
 * 
 * @author lijian
 * @since 2008-5-27
 * @version 1.0
 */
public class DepartmentServiceImpl implements IDepartmentService {
	
	private IDepartmentDao departmentDao;

	/**
	 * 读取系统部门信息
	 * 
	 * @param id
	 * @return Tdepartment 对象
	 * @throws BusiException 
	 */
	public Tdepartment loadDepartment(Long id) throws BusiException{
		if(id != null)
			return departmentDao.loadDepartment(id);
		else
			throw new BusiException("传入参数为空");
	}

	/**
	 * 删除系统部门信息
	 * 
	 * @param department
	 * @throws BusiException 
	 */
	public void deleteDepartment(Tdepartment department) throws BusiException{
		if(department != null)
			departmentDao.deleteDepartment(department);
		else
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 删除系统部门信息
	 * 
	 * @param id 系统部门Id
	 * @throws BusiException 
	 */
	public void deleteDepartmentById(Long id) throws BusiException{
		if(id != null){
			Tdepartment department = departmentDao.loadDepartment(id);
			departmentDao.deleteDepartment(department);
		}
		else
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 更新系统部门信息
	 * 
	 * @param department
	 * @throws BusiException 
	 */
	public void updateDepartment(Tdepartment department) throws BusiException{
		if(department != null)
			departmentDao.updateDepartment(department);
		else
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 保存系统部门信息
	 * 
	 * @param department
	 * @return Long 主键
	 * @throws BusiException 
	 */
	public Long saveDepartment(Tdepartment department) throws BusiException{
		if(department != null)
			return departmentDao.saveDepartment(department);
		else
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 分页查询系统部门信息.
	 * 
	 * @param pagePoParam 查询参数
	 * @return IPageList IPageList对象
	 * @throws BusiException 
	 */
	public IPageList listByPage(PagePoParam pagePoParam) throws BusiException {
		if(pagePoParam != null)
			return departmentDao.listByPage(pagePoParam);
		else
			throw new BusiException("传入参数为空");
	}
	
	public void setDepartmentDao(IDepartmentDao departmentDao) {
		this.departmentDao = departmentDao;
	}
}
